<template>
  <DataList :cate="cate" :name="name" :single="true" :cols="cols" />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addZsjh, deleteZsjh, updateZsjh, getZsjh } from "@/api/招生计划.js";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A1-3 招生计划",
      name:'1.3 招生计划',
      cols: [
       { label: "全日制高职专业设置数(不含方向)(个)", prop: "DNQRZGZZSJHZYSZS" },
       { label: "全日制高职招生专业数(不含方向)(个)", prop: "DNQRZGZZSJHZYS" },
       { label: "全日制高职招生数(人)", prop: "DNQRZGZZSJHS" },  

       { label: "其中",
       data:[
            {label:"普通高中生",data:[
                {label:"招生数(人)",prop:"ZSS_PTGZ_ZSS"},
                {label:"比例(%)",prop:"ZSS_PTGZ_BL"}
                ]
            },
            {label:"“三校生”",data:[
                {label:"招生数(人)",prop:"ZSS_SXS_ZSS"},
                {label:"比例(%)",prop:"ZSS_SXS_BL"}
                ]
            },
            {label:"“3+2”",data:[
                {label:"招生数(人)",prop:"ZSS_SJE_ZSS"},
                {label:"比例(%)",prop:"ZSS_SJE_BL"}
                ]
            },
            {label:"五年制高职第4学年",data:[
                {label:"招生数(人)",prop:"ZSS_WNZ_ZSS"},
                {label:"比例(%)",prop:"ZSS_WNZ_BL"}
                ]
            },
            {label:"其他",data:[
                {label:"招生数(人)",prop:"ZSS_QT_ZSS"},
                {label:"比例(%)",prop:"ZSS_QT_BL"}
                ]
            },

        ]}       
      ]
    };
  },
      methods:{
      
        async fetchData() {
        var user = getUser();
        var datas = await getZsjh(user.XXID,user.CJPC);
     
        return datas;
    },
    
    async  onChange(model, field, value) {
      
          
         model.DNQRZGZZSJHS = Number(model.ZSS_PTGZ_ZSS)+Number(model.ZSS_SXS_ZSS)+Number(model.ZSS_SJE_ZSS)+Number(model.ZSS_WNZ_ZSS)+Number(model.ZSS_QT_ZSS);
         model.ZSS_PTGZ_BL = ((Number(model.ZSS_PTGZ_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_SXS_BL = ((Number(model.ZSS_SXS_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_SJE_BL = ((Number(model.ZSS_SJE_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_WNZ_BL = ((Number(model.ZSS_WNZ_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_QT_BL = ((Number(model.ZSS_QT_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
       
      //
    },
     onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addZsjh(temp);
          resolve(model);
      })
      
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateZsjh(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteZsjh(temp);
          resolve();
      })
    }
        }
};
</script>
<style>
</style>